/*
 *  Copyright 2010 johan.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package nu.zoom.catonine.stylerule;

import java.awt.Color;
import java.util.regex.Pattern;

/**
 * Factory class to create default sets of styling rules.
 * 
 * @author "Johan Maasing" &lt;johan@zoom.nu&gt;
 */
public class SampleStyleRulesFactory {

	public static StyleRules getLog4JStyleRules() {
		StyleRules rules = new StyleRules("Log4J");
		rules.setLogBlockPatternBeginsBlock(true);
		rules.setLogBlockPattern(Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d"));

		StyleRule error = new StyleRule();
		error.setPattern(".*ERROR.*");
		error.setBackground(Color.RED);
		rules.add(error);

		StyleRule warn = new StyleRule();
		warn.setPattern(".*WARN.*");
		warn.setBackground(Color.YELLOW);
		rules.add(warn);

		StyleRule trace = new StyleRule();
		trace.setPattern(".*TRACE.*");
		trace.setForeground(Color.DARK_GRAY);
		rules.add(trace);

		return rules;
	}

	public static StyleRules getSyslogStyleRules() {
		StyleRules rules = new StyleRules("Syslog");
		rules.setLogBlockPatternBeginsBlock(false);
		rules.setLogBlockPattern(Pattern.compile("((\\n\\r?)|(\\r\\n?))"));

		StyleRule kernel = new StyleRule();
		kernel.setPattern(".*kernel.*");
		kernel.setBackground(new Color(204, 255, 204));
		rules.add(kernel);

		StyleRule cron = new StyleRule();
		cron.setPattern(".*CRON.*");
		cron.setForeground(new Color(51, 0, 51));
		rules.add(cron);

		return rules;

	}
}
